/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ArquivoServidor;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author saracristhina
 */
public class Arquivo {
    InputStream is;
    InputStreamReader isr;
    BufferedReader br;
    static LinkedList dic;

    //escrever um método que recebe os dados do 
    //cliente e compara com os do arquivo do servidor

    public Arquivo() {
        this.dic = new LinkedList();
        try {
            this.is = new FileInputStream("src/dic/en_US.dic");
            this.isr = new InputStreamReader(this.is);
            this.br = new BufferedReader(this.isr);
            try {
                String s = br.readLine();
                
                while (s != null){
                    dic.add(s);
                  //  System.out.println(s);
                    s = br.readLine();
                }
            } catch (IOException ex) {
                Logger.getLogger(Arquivo.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Arquivo.class.getName()).log(Level.SEVERE, null, ex);
        }
//        LinkedList test = new LinkedList();
//            String t = "Monroe/M";
//            test.addFirst(t);
//            String s = "monotonous/YP";
//            test.addFirst(s);
//            String h = "absolutism";
//            test.addFirst(h);
            
//        pointsCalc(dic,list);
    }
    public static int pointsCalc( LinkedList arc){
        int count = 0;
        LinkedList ll = Arquivo.dic;
        
        for (Iterator it = arc.iterator(); it.hasNext(); ) {
            String arcCurrent = (String) it.next();

            for (Iterator iterator = ll.iterator(); iterator.hasNext(); ) {    
                String current = (String) iterator.next();
                    
                if(current.equals(arcCurrent.toUpperCase())){
                    System.out.println (current);
                    count = count + current.length();
                }
            } 
        }
        return count;
    }
}
